<template>
	<view class="page-head" :style="{ 'padding-top': paddingTop + 'px' }">
		<!-- logo，使用image组件显示猫咪的LOGO -->
		<view class="logo-contanier">
			<image class="logo-image" :src="logoSrc" mode="aspectFit"></image>
		</view>
		<!-- 顶部搜索栏 -->
		<view class="search-bar">
			<input type="text" placeholder="华为P40">
		</view>
		<view>
			<!-- 轮播图 -->
			<view class="uni-margin-wrap">
				<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="2000"
					:duration="500">
					<swiper-item>
						<view class="swiper-item">
							<image class="banner-img" src="/static/sign-in/gift.png"></image>
						</view>
					</swiper-item>
					<swiper-item>
						<view class="swiper-item">
							<image class="banner-img" src="/static/qr.png"></image>
						</view>
					</swiper-item>
					<swiper-item>
						<view class="swiper-item">
							<image class="banner-img" src="/static/banner3.jpg"></image>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<!-- 分类图标 -->
			<view class="category-icons">
				<view class="category-item">
					<image class="icon" src="/static/tab-icons/news.png"></image>
					<text>数码</text>
				</view>
				<view class="category-item">
					<image class="icon" src="/static/clothes.png"></image>
					<text>服饰</text>
				</view>
				<view class="category-item">
					<image class="icon" src="/static/book.png"></image>
					<text>书籍</text>
				</view>
				<view class="category-item">
					<image class="icon" src="/static/makeup.png"></image>
					<text>美妆</text>
				</view>
				<view class="category-item">
					<image class="icon" src="/static/other.png"></image>
					<text>其它</text>
				</view>
			</view>
			<!-- 商品推荐 -->
			<view class="product-recommendation">
				<view class="product-title">
					<text style="font-weight: bold;">商品推荐</text>
					<view class="sort-options">
						<text class="sort-item active">综合</text>
						<text class="sort-item">最新</text>
						<text class="sort-item">最热</text>
					</view>
				</view>
				<view class="product-list">
					<view class="product-item">
						<image class="product-img" src="/static/product1.jpg"></image>
						<view class="product-info">
							<text class="product-name" style="font-weight: bold;">阿米洛樱花键盘 九成新 阿米洛</text>
							<view class="product-user">
								<image class="user-avatar" src="/static/avatar1.png"></image>
								<text class="user-name">红茶小夹</text>
								<text class="product-price">¥9999.00</text>
							</view>
						</view>
					</view>
					<view class="product-item">
						<image class="product-img" src="/static/product2.jpg"></image>
						<view class="product-info">
							<text class="product-name" style="font-weight: bold;">阿米洛樱花键盘 九成新 阿米洛</text>
							<view class="product-user">
								<image class="user-avatar" src="/static/avatar1.png"></image>
								<text class="user-name">红茶小夹</text>
								<text class="product-price">¥9999.00</text>
							</view>
						</view>
					</view>
					<view class="product-item">
						<image class="product-img" src="/static/product2.jpg"></image>
						<view class="product-info">
							<text class="product-name" style="font-weight: bold;">阿米洛樱花键盘 九成新 阿米洛</text>
							<view class="product-user">
								<image class="user-avatar" src="/static/avatar1.png"></image>
								<text class="user-name">红茶小夹</text>
								<text class="product-price">¥9999.00</text>
							</view>
						</view>
					</view>
					<view class="product-item">
						<image class="product-img" src="/static/product2.jpg"></image>
						<view class="product-info">
							<text class="product-name" style="font-weight: bold;">阿米洛樱花键盘 九成新 阿米洛</text>
							<view class="product-user">
								<image class="user-avatar" src="/static/avatar1.png"></image>
								<text class="user-name">红茶小夹</text>
								<text class="product-price">¥9999.00</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			mode: {
				type: String,
				default: "light"
			},
			url: {
				type: String,
				default: ""
			}
		},
		computed: {
			logoSrc() {
				let light = '/static/logo/logo.png';
				let black = "/static/logo/logo-white.png";
				let srcMap = {
					light,
					black
				}
				return srcMap[this.mode];
			}
		},
		data() {
			return {
				paddingTop: 0
			}
		},
		mounted() {
			// #ifdef MP-WEIXIN
			let MenuButtonBoundingClientRect = uni.getMenuButtonBoundingClientRect();
			this.paddingTop = MenuButtonBoundingClientRect.top;
			// #endif
		},
		methods: {
			handleToSearchPage() {
				// 跳转
				uni.navigateTo({
					url: this.url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* 顶部搜索栏样式 */
	.search-bar {
		height: 80rpx;
		background-color: #00bfff;
		display: flex;
		align-items: center;
		padding: 0 20rpx;
	}

	.logo {
		width: 60rpx;
		height: 60rpx;
		margin-right: 20rpx;
	}

	input {
		flex: 1;
		height: 60rpx;
		border: none;
		border-radius: 10rpx;
		padding: 0 20rpx;
	}

	/* 轮播图样式 */
	.uni-margin-wrap {
		width: 100%;
	}

	.swiper {
		height: 300rpx;
	}

	.swiper-item {
		display: block;
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
	}

	.banner-img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	/* 分类图标样式 */
	.category-icons {
		display: flex;
		justify-content: space-around;
		padding: 20rpx 0;
	}

	.category-item {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.icon {
		width: 80rpx;
		height: 80rpx;
		margin-bottom: 10rpx;
	}

	/* 商品推荐样式 */
	.product-recommendation {
		padding: 20rpx;
	}

	.product-title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.sort-options {
		display: flex;
	}

	.sort-item {
		margin-left: 20rpx;
		color: #808080;
	}

	.active {
		color: #00bfff;
	}

	.product-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.product-item {
		width: 48%;
		margin-bottom: 20rpx;
		border: 1rpx solid #e0e0e0;
		border-radius: 10rpx;
		overflow: hidden;
	}

	.product-img {
		width: 100%;
		height: 200rpx;
		object-fit: cover;
	}

	.product-info {
		padding: 10rpx;
	}

	.product-name {
		font-size: 28rpx;
		margin-bottom: 10rpx;
	}

	.product-user {
		display: flex;
		align-items: center;
	}

	.user-avatar {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		margin-right: 10rpx;
	}

	.user-name {
		font-size: 24rpx;
		margin-right: 10rpx;
	}

	.product-price {
		color: red;
		font-size: 28rpx;
	}

	.custom-scroll-view {
		width: 100%;
		height: 100%;

		scroll-view {
			width: 100%;
			height: 100%;

			.status-container {
				text-align: center;
				padding-bottom: 32rpx;
				padding-top: 32rpx;

				// 列表数据为空时展示容器
				.data-empty {
					box-sizing: border-box;
					padding: 64px 0;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.empty__image {
						width: 320rpx;
						height: 320rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}

					.empty__description {
						margin-top: 32rpx;
						padding: 0 120rpx;
						color: #969799;
						font-size: 28rpx;
						line-height: 40rpx;
					}
				}

				.text {
					font-size: 24rpx;
					color: #ccc
				}
			}
		}
	}

	.page-head {
		padding: 0 32rpx;
		padding-bottom: 8rpx;
		box-sizing: border-box;

		// logo区域
		.logo-contanier {
			display: flex;
			align-items: center;
			z-index: 1;
			position: relative;

			.logo-image {
				width: 310rpx;
				height: 128rpx;
			}

			.logo-text {
				width: 180rpx;
				height: 56rpx;
				margin-left: 20rpx;
			}
		}

		// 搜索区域
		.search-container {
			margin-top: -10rpx;
			z-index: 0;
			position: relative;

			// 因组件库无法满足圆角需求 故改为deep方式改变样式
			::v-deep(.uni-easyinput__content) {
				border-radius: 24rpx !important;
			}
		}
	}

	.page-contanier {
		background-color: #fff;

		.head-container {
			position: relative;
			z-index: 999;
			width: 100%;
			background: #3FD3D1;
			overflow: hidden;
		}

		.content-container {
			width: 100%;
			height: calc(100vh - var(--window-bottom) - 200rpx);

			.arc-container {
				width: 100%;
				height: 80rpx;
				background: #3FD3D1;
				border-radius: 0rpx 0rpx 50% 50%;
			}

			.swiper-container {
				padding: 0px 16px 0 16px;

				.swiper-view {
					margin-top: -45rpx;
					margin-bottom: 38rpx;
					height: 220rpx;
					width: 100%;

					.image-container {
						height: 100%;
						width: 100%;
						border-radius: 16rpx;
					}
				}
			}

			.classify-container {
				padding: 0px 16px 0 16px;

				.used-classify {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.user-classify-item {
						height: 100%;
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: center;

						image {
							width: 100rpx;
							height: 100rpx;
						}

						text {
							font-size: 24rpx;
						}
					}
				}
			}

			.used-recommend-container {
				position: sticky;
				top: 0;
				left: 0;
				z-index: 9999;
				background-color: #fff;
				padding: 24rpx 16px 24rpx 16px;

				.container {
					height: 65rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				.right {
					width: 200rpx;
				}
			}

			.waterfalls-flow-container {
				padding: 32rpx;
				box-sizing: border-box;

				// max-height: 400rpx !important;
				.waterfalls-flow {
					padding: 0 4rpx;
				}

				.info-container {
					padding: 16rpx;
					box-sizing: border-box;

					.title {
						display: inline-block;
						width: 100%;
						overflow: hidden;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 1;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.item-info {
						margin-top: 20rpx;
						display: flex;
						align-items: center;

						image {
							width: 48rpx;
							height: 48rpx;
							border-radius: 48rpx;
							flex-shrink: 0;
						}

						.user-info-name {
							font-size: 24rpx;
							font-weight: 350;
							color: #666666;
							margin-left: 16rpx;
							display: inline-block;
							width: 100%;
							overflow: hidden;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 1;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.user-info-price {
							flex-shrink: 0;
							font-size: 32rpx;
							font-weight: 700;
							color: #FF756A;
							text-align: right;
						}
					}
				}
			}
		}
	}
</style>